<template>
  <el-tag :type="item?.type" :color="item?.color">{{ item?.title }}</el-tag>
</template>

<script setup>
import { computed } from 'vue'

const props = defineProps({
  codeList: {
    type: Array,
    default: () => [{ title: '', color: '', type: '', state: 0 }],
  },
  state: {
    default: 1,
    type: Number,
  },
})
console.log(props.codeList, props.state)

const item = computed(() => {
  return props.codeList.find((item) => {
    if (item.state === props.state)
      return {
        title: (item.title && item.title) || '',
        color: (item.color && item.color) || '',
        type: (item.type && item.type) || '',
      }
  })
})
</script>

<style scoped lang="scss"></style>
